{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "08470cc5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "嘿，请输入您的账号：哈哈哈\n",
      "嘿，请输入您的密码：123\n",
      "您输入的账号或密码不正确，请重新输入，您还有 2 次机会~加油~\n",
      "嘿，请输入您的账号：2hi\n",
      "嘿，请输入您的密码：245\n",
      "您输入的账号或密码不正确，请重新输入，您还有 1 次机会~加油~\n",
      "嘿，请输入您的账号：2234\n",
      "嘿，请输入您的密码：345\n",
      "您已经使用完3次机会了，拜拜，5分钟后再会\n"
     ]
    }
   ],
   "source": [
    "# 简单的数据结构有 ： 数值和字符串\n",
    "# 模拟数据库数据 复杂的数据结构：\n",
    "user_data = [\"biyan\"]\n",
    "password_data = [\"123456\"]\n",
    "\n",
    "count = 3\n",
    "while True:\n",
    "    count -= 1\n",
    "    # 用户输入数据\n",
    "    username = input(\"请输入您的学号：\")\n",
    "    password = input(\"请输入您的密码：\")\n",
    "    # 1. 先判断账号\n",
    "    if user_data == username:\n",
    "        if password_data == password:\n",
    "            # 占位符%s\n",
    "            print(\"欢迎%s登录系统使用~\"%(username))\n",
    "            break\n",
    "        else:\n",
    "            if count == 0:\n",
    "                print(\"您已经使用完3次机会了，拜拜，5分钟后再会\")\n",
    "                break\n",
    "            else:\n",
    "                print(\"您输入的账号或密码不正确，请重新输入，您还有\",count,\"次机会~加油~\")\n",
    "    else:\n",
    "        if count == 0:\n",
    "            print(\"您已经使用完3次机会了，拜拜，5分钟后再会\")\n",
    "            break\n",
    "        else:\n",
    "            print(\"您输入的账号或密码不正确，请重新输入，您还有\",count,\"次机会~加油~\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "189c59f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\ncount = 0\\nwhile True:\\n    # count = count+1\\n    count +=5\\n    print(\"你是风儿我是沙,缠缠绵绵到天涯...\",count)\\n    if count == 100:\\n        break\\n'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#登录系统\n",
    "\n",
    "#用户输入的数据 VS 数据库的数据\n",
    "# 优化 ： 1. 输入不正确时继续输入。 2.设置输入失败的次数\n",
    "\n",
    "# while True + count 计数器  VS  for循环 + range()\\\n",
    "# while True + 结束条件\n",
    "'''\n",
    "count = 0\n",
    "while True:\n",
    "    # count = count+1\n",
    "    count +=5\n",
    "    print(\"你是风儿我是沙,缠缠绵绵到天涯...\",count)\n",
    "    if count == 100:\n",
    "        break\n",
    "'''\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06031c39",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
